function [] = guicheck(h_menu, on_off, varargin);

% GUICHECK - place/remove check mark next to specified menu items
%
%    GUICHECK(H_MENU, 'on', P1, V1, P2, V2, ...) places a check
%    mark next to the menu items residing in the menu H_MENU.
%    The items to be checked possess property values matching
%    those specified by the property name/value pairs Pi/Vi.  The
%    property name Pi must be a string and the property values Vi
%    are cell arrays containing the property value for each item
%    to be checked.
%
%    GUICHECK(H_MENU, 'off', P1, V1, P2, V2, ...) removes a check
%    mark from the specified menu items.

% By:   S.C. Molitor (smolitor@med.unc.edu)
% Date: August 31, 1999

% check input parameters

if (nargin < 4)
   return
elseif (~istype(h_menu, 'uimenu') & ~istype(h_menu, 'uicontextmenu'))
   return
elseif (isempty(get(h_menu, 'Children')))
   return
elseif (~ischar(on_off))
   return
elseif (isempty(find(strcmp({'on', 'off'}, on_off))))
   return
end


% find objects with specified property name/value pairs
% place/remove check marks next to items that match property name/value pairs

h_item = mfindobj(h_menu, varargin{:});
for i = 1 : length(h_item)
   if (istype(h_item(i), 'uimenu'))
      set(h_item(i), 'Checked', on_off);
   end
end
return
